package com.smt.modules.bus.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import com.smt.common.base.BaseController;
import com.smt.modules.bus.vo.ConsumptionFileVo;
import com.smt.modules.bus.entity.ConsumptionFileEntity;
import com.smt.modules.bus.service.ConsumptionFileService;
import com.smt.common.utils.PageUtils;
import com.smt.common.utils.R;



/**
 * 消费文件表
 *
 * @author murong
 * @email 981620741@qq.com
 * @date 2018-10-17 10:06:53
 */
@RestController
@RequestMapping("bus/consumptionfile")
@Api(tags = {"ConsumptionFileController"},description = "消费文件表")
public class ConsumptionFileController extends BaseController{
    @Autowired
    private ConsumptionFileService consumptionFileService;

    /**
    * 查询消费文件表分页方法
    * @param params
    * @return
    */
    @PostMapping("/list")
    @RequiresPermissions("bus:consumptionfile:list")
    @ApiOperation(value = "/list",notes = "根据条件查询",response = ConsumptionFileVo.class)
    public R list(@RequestParam Map<String, Object> params){
//        PageUtils page = consumptionFileService.queryPage(params);
//
//        return R.ok().put("page", page);
        return null;
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    @RequiresPermissions("bus:consumptionfile:info")
    @ApiOperation(value = "/info/{id}",notes = "根据表ID查询",response = ConsumptionFileVo.class)
    public R info(@PathVariable("id") Long id){
			ConsumptionFileEntity consumptionFile = consumptionFileService.selectById(id);

        return R.ok().put("consumptionFile", consumptionFile);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @RequiresPermissions("bus:consumptionfile:save")
    @ApiOperation(value = "/save",notes = "添加信息保存",response = ConsumptionFileVo.class)
    public R save(@RequestBody ConsumptionFileEntity consumptionFile){
			consumptionFileService.insert(consumptionFile.copyPropertiesTo(new ConsumptionFileEntity()));

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    @RequiresPermissions("bus:consumptionfile:update")
    @ApiOperation(value = "/update",notes = "更新信息保存",response = ConsumptionFileVo.class)
    public R update(@RequestBody ConsumptionFileEntity consumptionFile){
			consumptionFileService.updateById(consumptionFile.copyPropertiesTo(new ConsumptionFileEntity()));

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    @RequiresPermissions("bus:consumptionfile:delete")
    @ApiOperation(value = "/delete",notes = "批量删除",response = ConsumptionFileVo.class)
    public R delete(@RequestBody Long[] ids){
			consumptionFileService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
